public class Test {
    public static void main(String[] args) {
        TreeNode root = new TreeNode(3,new TreeNode(5),new TreeNode(1));
        root.left.left = new TreeNode(6);
        root.left.right = new TreeNode(2,new TreeNode(7),new TreeNode(4));
        root.right.left = new TreeNode(0);
        root.right.right = new TreeNode(8);

        TreeNode p = root.left;
        TreeNode q = root.right;

        Solution solution = new Solution();
        TreeNode cur = solution.lowestCommonAncestor(root,p,q);
        System.out.println(cur.val);
    }
}
